/*
回文字串
http://acm.pku.edu.cn/JudgeOnline/problem?id=1159
*/

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int n, i, j;
char s1[5005], s2[5005];
unsigned short dp[5005][5005];
int main()
{
    while (scanf("%d", &n)!=EOF) {
        scanf("%s", s1);
        for (i=0; i<n; ++i)
            s2[i] = s1[n-i-1];
        s2[n] = 0;
        dp[0][0] = (s1[0] == s2[0]);
        for (i=0; i<n; ++i)
            for (j=0; j<n; ++j) {
                dp[i][j] = (s1[i] == s2[j]);
                if (i>0 && j>0) dp[i][j] += dp[i-1][j-1];
                if (i>0) dp[i][j] = max(dp[i][j], dp[i-1][j]);
                if (j>0) dp[i][j] = max(dp[i][j], dp[i][j-1]);
            }    
        printf("%d\n", n-dp[n-1][n-1]);
    }    
    return 0;
}    
